<?php

namespace app\api\controller;

use app\api\validate\ThemeValidate;
use think\Controller;
use think\Request;
use app\api\model\Theme as ThemeModel;

/**
 * 主题
 * Class Theme
 * @package app\api\controller
 */
class Theme extends Common
{

    /**
     * 主题列表
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \app\lib\exception\ThrowError
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getThemeList()
    {
        $themeList = ThemeModel::getThemeList();
        if ($themeList->isEmpty())
        {
            T(300000);
        }
        return $this->response($themeList);
    }

    /**
     * 获取主题详情的内容列表
     * @param $themeId
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \app\lib\exception\ThrowError
     */
    public function getThemeDetail($themeId)
    {
        (new ThemeValidate('getThemeDetail'))->goCheck();
        $themeDetail = ThemeModel::getThemeDetail($themeId);
        if (!$themeDetail)
        {
            T(300001);
        }
        return $this->response($themeDetail);
    }
}
